100 585
(Remember to subtract the 15 cent service charge.)
All objects automatically have a toString()
method
that returns a reference to a string for the object.
The compiler puts in a toString()
method even if you did not write it.
This mechanism is called inheritance and is the subject of a upcoming chapter.
The following statement could be put in main()
:
System.out.println( account1.toString() );
This is what it prints:
CheckingAccount@15db9742
Not very informative.
It would be useful if the toString()
method made a string
that showed the current state of the object.
Fill in the blanks below to complete the method.
Note: the reserved word public
must be there.
The chapter on inheritance will explain this further.
Fill in the blanks. The "\t" in the strings represents the tab character.